﻿#include "Common/DataProc/DataProc.h"
#include "HAL.h"
#include <stdlib.h>

static HAL::CommitFunc_t CommitFunc;
static void* UserData;

void HAL::IMU_SetCommitCallback(CommitFunc_t func, void* userData)
{
	CommitFunc = func;
	UserData = userData;
}

void HAL::IMU_Update()
{
	static int16_t steps;
	steps++;
	if (steps > 9999) {
		steps = 0;
	}

	IMU_Info_t imu;
	imu.steps = steps;

	imu.ax = rand() % 1000 - 500;
	imu.ay = rand() % 1000 - 500;
	imu.az = rand() % 1000 - 500;
	imu.gx = rand() % 1000 - 500;
	imu.gy = rand() % 1000 - 500;
	imu.gz = rand() % 1000 - 500;

	if (CommitFunc) {
		CommitFunc(&imu, UserData);
	}
}
